package com.yuanfeng.job.job;

import com.yuanfeng.job.mapper.WxLiveHostMapper;
import com.yuanfeng.job.utils.WxLiveUtil;
import com.yuanfeng.job.vo.QuWxGoodsListVO;
import com.yuanfeng.job.vo.QuWxGoodsVO;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @ClassName UpdateWxLiveGoodsJob
 * @Description 更新小程序直播商品状态
 * @Author liulh
 * @Date 2023/5/17 11:45
 * @Version 1.0
 **/
public class UpdateWxLiveGoodsJob implements BaseJob {

    @Autowired
    private WxLiveUtil wxLiveUtil;

    @Autowired
    private WxLiveHostMapper wxLiveHostMapper;

    private static final Logger logger = LoggerFactory.getLogger(UpdateWxLiveGoodsJob.class);

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        try {
            QuWxGoodsListVO quWxGoodsListResult = wxLiveUtil.queryWxLiveGoodsList("0", "2");
            List<QuWxGoodsVO> goodIds = quWxGoodsListResult.getGoods();
            Integer integer = wxLiveHostMapper.upLiveGoodsiIsverify(1, goodIds, "微信审核通过");
            logger.info("小程序已审核列表更新完成");

            QuWxGoodsListVO goodsListResult = wxLiveUtil.queryWxLiveGoodsList("0", "3");
            List<QuWxGoodsVO> goods = goodsListResult.getGoods();
            Integer count = wxLiveHostMapper.upLiveGoodsiIsverify(3, goods, "微信审核不通过");
            logger.info("小程序审核不通过列表更新完成");

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
